package com.bysc.service.serviceImpl;

import com.bysc.mapper.TasksMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bysc.pojo.entity.Task;
import com.bysc.service.TasksService;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class TasksServiceImpl implements TasksService {

    @Autowired
    private TasksMapper tasksMapper;

    /**
     * 查询全部任务
     * @return
     */
    @Override
    public List<Task> getAllTask() {

        List<Task> taskList = tasksMapper.select();

        return taskList;
    }

    /**
     * 根据id删除任务
     * @param id
     */
    @Override
    public void deleteById(Integer id) {
        tasksMapper.deleteById(id);
    }

    /**
     * 添加任务
     * @param task
     */
    @Override
    public void add(Task task) {
        task.setCreated_at(LocalDateTime.now());

        tasksMapper.insert(task);
    }
}
